<?php
/* @var $this UserController */
/* @var $user_id */
$this->main_menu = MenuHelper::getArrayForMainMenu(true, false, false);
?>

<?php
$this->widget('bootstrap.widgets.TbTabs', array(
	'type'=>'tabs', // 'tabs' or 'pills'
	'tabs'=>array(
		array('label'=>'Alle Kunden', 'url'=>$this->createUrl('user/admin'), 'active'=>false),
        array('label'=>'NEU', 'url'=>$this->createUrl('user/create'), 'active'=>false),
//                array('label'=>'|','itemOptions'=>array('class'=>'disabled'), 'url'=>$this->createUrl('user/getCourseForUser', array('id'=>$user_id))),
        array('label'=>'Stammdaten', 'url'=>$this->createUrl('user/update', array('id'=>$user_id)), 'active'=>false), 
        array('label'=>'Info', 'url'=>$this->createUrl('user/info', array('user_id'=>$user_id)), 'active'=>false),
        array('label'=>'Rechnungsadressen', 'url'=>$this->createUrl('user/viewInvoiceAddresses', array('user_id'=>$user_id)), 'active'=>false),
        array('label'=>'Kurse', 'url'=>$this->createUrl('user/getCourseForUser', array('id'=>$user_id)), 'active'=>true),
//                array('label'=>'|','itemOptions'=>array('class'=>'disabled'), 'url'=>$this->createUrl('user/getCourseForUser', array('id'=>$user_id))),
	),
));
?>

<?php

    $model = Course::model();

    $user = User::model()->findByPk($user_id);
    $courses = new CArrayDataProvider($user->courses, array(
       'keyField' => 'course_id', 
    ));
?>

<?php

    $this->widget('bootstrap.widgets.TbExtendedGridView', array(
//    'filter'=>$model,
    'fixedHeader' => true,
    'headerOffset' => 40, 
    'type'=>'striped bordered',
    'dataProvider' => $courses,
    'template' => '{items}{pager}', // 2nd way
//    'template' => "{items}",
	'columns'=>array(
//            'first_name',
            array(
                'name'=>'Kurs',
                'value'=>'$data->course_nr',
            ),
            array(
                'name'=>'Ort',
                'value'=>'$data->place',
            ),
            array(
                'name'=>'Titel',
                'value'=>'$data->title',
            ),
            array(
                'name'=>'Beginn',
                'value'=>'$data->start',
            ),
//            'last_name',
            array (
                'class'=>'CButtonColumn',
                'template'=>'{stornieren}',
                'buttons' => array(
                  'stornieren' => array(
                    'url'=>'Yii::app()->createUrl("user/deleteUserFromCourse", array("course_id"=>$data->course_id, "user_id"=>' . $user_id . '))',  
                  ),
                ),
            ),
	),
    ));
?>

<div id="bottom">

<?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'label' => 'Kurs zubuchen',
        'size' => 'medium',
        'url' => $this->createUrl('user/addUserToCourse', array('course_id'=>null, 'user_id'=>$user_id)),
    ));
?>

</div>